﻿import 'package:flutter/material.dart';
import 'package:get/get.dart';
import 'package:vischat/core/annotations/getx_route_enhanced.dart';
import 'package:vischat/data/models/posts_model.dart';
import 'package:vischat/modules/home/posts/posts_controller.dart';
import 'package:vischat/modules/home/posts/widgets/posts_card_shimmer.dart';
import 'package:vischat/shared/widgets/shimmer/app_shimmer.dart';
import 'package:vischat/shared/widgets/top_search.dart';
import 'package:vischat/shared/widgets/view_list/view_list.dart';

@GetXRoute('/posts')
class PostsPage extends GetView<PostsController> {
  const PostsPage({super.key});

  @override
  Widget build(BuildContext context) {
    return Scaffold(
      body: SafeArea(
        child: Column(
          children: [
            TopSearch(search: controller.search),
            Expanded(
              child: ViewList<PostsController, PostsModel>(
                controller: controller,
                listBuilder:
                    () => ListView.builder(
                      itemCount: controller.list.length,
                      itemBuilder:
                          (_, index) => Container(
                            color: Colors.white,
                            child: const AppShimmer(child: PostsCardShimmer()),
                          ),
                    ),
              ),
            ),
          ],
        ),
      ),
    );
  }
}
